const babel = require("@babel/core");
const types = require("@babel/types");
const transformFunction = require("babel-plugin-transform-es2015-arrow-functions");

const code = "const add = (a, b) => a + b";

const result = babel.transform(code, {
  // plugins: [] 某一个单独的插件
  // presets: [] 很多插件的集合

  plugins: [transformFunction],
});

console.log("generate code:", result.code);
